#include "stdafx.h"
#include "Material.h"

#include "Perlin.h"

using namespace rt;

XMVECTOR Material::GetProcTexColor(XMVECTOR texCoords)
{
	float tx = XMVectorGetX(texCoords) * 14.1f;
	float ty = XMVectorGetY(texCoords) * 14.1f;
	float tz = XMVectorGetZ(texCoords) * 14.1f;
	switch(ProcTex)
	{
	case NOISE:
		{
			//float noi = noise(tx, ty, tz);
			//return XMVectorReplicate(noi * 0.5f + 0.5f);

			float noiseCoef = 0.0f;
			for (int level = 1; level < 10; level ++)
			{
				noiseCoef += (1.0f / level ) 
					* fabsf(noise(level * 0.05 * tx, 
					level * 0.05 * ty,
					level * 0.05 * tz));
			};


			return XMVectorReplicate(noiseCoef);
		}

	case MARBLE:
		{

		}
		
		break;

	default:
		return XMVectorSplatOne();
	}

}